package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.DistributorAgencyOfflineMonthBill;

public class DistributorAgencyOfflineMonthBillWrapper {
	
	SqlManager manager;

	public DistributorAgencyOfflineMonthBillWrapper() {
		manager = new SqlManager("shenqisettlement");
	}

	@SuppressWarnings("unchecked")
	public DistributorAgencyOfflineMonthBill selectByPrimaryKey(Long id) {

		DistributorAgencyOfflineMonthBill distributorAgencyOfflineMonthBill = null;
		List<DistributorAgencyOfflineMonthBill> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.DistributorAgencyOfflineMonthBillMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			distributorAgencyOfflineMonthBill = result.get(0);
		}

		return distributorAgencyOfflineMonthBill;
	}
	
	public int updatePaid(Long id, int paid) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("id", id);
		map.put("paid", paid);
		
		int result = manager
				.update("com.ymttest.database.mapping.shenqisettlement.DistributorAgencyOfflineMonthBillMapper.updatePaid",
						map);
		manager.commit();

		return result;
	}
	
	public int updateReceived(Long id, int received) {

		HashMap<String, Object> map = new HashMap<>();

		map.put("id", id);
		map.put("received_confirmed", received);
		
		int result = manager
				.update("com.ymttest.database.mapping.shenqisettlement.DistributorAgencyOfflineMonthBillMapper.updateReceived",
						map);
		manager.commit();

		return result;
	}
	
	public static void main(String[] args) {
		
		DistributorAgencyOfflineMonthBillWrapper test = new DistributorAgencyOfflineMonthBillWrapper();

		System.out.println(test.updatePaid(3L, 0));
	}
}
